package cn.wolfcode.crm.web.controller;

import cn.wolfcode.crm.domain.Menu;
import cn.wolfcode.crm.query.QueryObject;
import cn.wolfcode.crm.serivce.IMenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("menu")
public class MenuController {
    @Autowired
    private IMenuService service;

    @RequestMapping("view")
    public String view() throws Exception {
        return "menu";
    }

    @ResponseBody
    @RequestMapping("selectRootMenu")
    public List<Menu> listAll() throws Exception {
        List<Menu> menus =service.selectRootMenu();
        return menus;
    }
    @ResponseBody
    @RequestMapping("selectByRoleId")
    public List<Long> selectByRoleId(Long roleId) throws Exception {
        List<Long> menus =service.selectByRoleId(roleId);
        return menus;
    }

    /**
     * 针对当前用户的菜单
     * @return
     * @throws Exception
     */
    @ResponseBody
    @RequestMapping("selectEmployeeMenu")
    public List<Menu> selectEmployeeMenu() throws Exception {
        List<Menu> menus =service.selectEmployeeMenu();
        return menus;
    }
}
